#chr15   62929370        62937380        NR_026897       MGC15885        human   hg19
f = open("/Users/jake/local/lux/hg19.tsv", "r")
hg19dic = {}
search = ""

for line in f.readlines():
	tk = line.strip().split("\t")
	hg19dic[tk[4]] = ":".join(tk[0:2]) + "-" + tk[2]
f.close()

out = open("fatgenes.js", "w")
out.write("var adipoflux_genes = {\n");
rec = ""
rec2 = ""
rec3 = ""

f2 = open("recon1entrez2symbol.txt", "r")
for line in f2.readlines():
	gene = line.strip().split("\t")[1]
	search =  search + "&quot;" + gene + "&quot;,"
	ekey = line.strip().split("\t")[0]
	if (hg19dic.get(gene) == None):
		print gene + " not found in hg19.tsv"
	else:
		pos = hg19dic.get(gene)
		rec2 = rec2 + "'%s':'%s',\n" %(ekey, gene)
		rec = rec + "'%s':'%s',\n" %(gene, pos)
		rec3 = rec3 + "'%s':'%s',\n" %(gene, ekey)
f2.close()
out.write(rec[:-2] + "};\n")
out.write("var adipoflux_ids = {\n");
out.write(rec2[:-2] + "};\n")
out.write("var adipoentrez_ids = {\n");
out.write(rec3[:-2] + "};\n")
out.close()
print search[:-2]
